package cn.itcast.erp.service.impl;

import cn.itcast.erp.dao.mapper.CStoreDetailMapper;
import cn.itcast.erp.dao.mapper.StoreMapper;
import cn.itcast.erp.entity.Emp;
import cn.itcast.erp.entity.Inventory;
import cn.itcast.erp.entity.Storealert;
import cn.itcast.erp.entity.Storedetail;
import cn.itcast.erp.entity.utils.AjaxResult;
import cn.itcast.erp.service.CStoreDetailService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 库存Service类
 * @author 丛平
 * @date 2019/6/11
 */

@Service("storeDetailService")
public class CStoreDetailServiceImpl implements CStoreDetailService {

    @Resource
    private CStoreDetailMapper cStoreDetailMapper;


    //分条件查询
    @Override
    public AjaxResult findStoreDetail(Storedetail storedetail) {
        AjaxResult ar = new AjaxResult();
        int total = this.cStoreDetailMapper.count();
        List<Storedetail> list = this.cStoreDetailMapper.findStoreDetail(storedetail);
        ar.setTotal(total);
        ar.setRows(list);
        return ar;
    }


    //不分页
    @Override
    public List<Storedetail> findAllStoreDetail() {
        return this.cStoreDetailMapper.findAllStoreDetail();
    }


    //库存预警
    @Override
    public AjaxResult findStorealert(Storealert storealert) {
        AjaxResult ar = new AjaxResult();
        int total = this.cStoreDetailMapper.countAlert();
        List<Storealert> list = this.cStoreDetailMapper.findStorealert(storealert);
        // TODO: 2019/6/14 一般 代码格式不规范
        ar.setTotal(total);
        ar.setRows(list);
        return ar;
    }




}
